<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>商户会员资料</title>
<link href="../style/css_member.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/common.js"></script>
<script src="../js/artDialog.js?skin=gray"></script>
<script src="../js/artDialog.iframeTools.js"></script>
<script type="text/javascript" src="../js/jquery-1.3.2.js"></script>

<script type="text/javascript">

	function modifyUserinfo(){

		  var username = $("#username").val().trim();
		  if( username  ==  ""){
			  $("#username").focus();
			  alert("用户姓名不能为空。");
			  return false;
		  }

		  var mobile = $("#mobile").val().trim();
		  if(!checkMobilePhone(mobile)){
			    $("#mobile").focus();
				return false;
		  }
		  
		  if(window.confirm("您确认修改个人会员资料吗？")){
			  $("#userInfoFrom").submit();
		  }
	}


	$(function(){

		var administratorFlag =  '${userInfo.administratorFlag}'; //是否为管理员
		
		if( administratorFlag == '0'){
			var city_id = '${userInfo.cityInfo.id}';
			checkCity(city_id);
		}

		var usertype = '${userInfo.userType}';
		if( usertype == "company" ){
			 chooseUserType(1);
		}
		else if( usertype == "personal" ){
			 chooseUserType(0);
		}
	});

	function checkForm(){

		 var companyName = $("#companyName").val().trim();
		 if( companyName  ==  ""){
			  $("#companyName").focus();
			  alert("请填写商户名称。");
			  return false;
		  }

		 var  usertype = $('input[name="userType"]:checked').val();
		 if( usertype == "company"){
			 var yyzh = $("#yyzh").val().trim();
			 if( yyzh  ==  ""){
				  $("#yyzh").focus();
				  alert("请填写营业执照注册号。");
				  return false;
			  }
		 }

		 if( usertype == "personal" ){
			  var idCard = $("#idCard").val().trim();
			  var idCardReg = /^(\d{14}|\d{17})(\d|[xX])$/; 
			  if( !idCardReg.test(idCard)){
				  $("#idCard").val("");
				  $("#idCard").focus();
				  alert("身份证号码填写错误。");
				  return false;
			  }
		 }

			var province = $("#provinceInfoSelect").val();
			if( province == ""){
				 alert("请选择所在省。");
				 return false;
			}

			var city = $("#cityInfoSelect").val();
			if( city == ""){
				 alert("请选择所在市县。");
				 return false;
			}
			
			var address = $.trim($("#address").val());
			if( address  ==  ""){
				$("#address").focus();
				alert("请填写区县及街道地址。");
				return false;
			}

			var zipCode = $.trim($("#zipCode").val());
			var zipCodeReg = /^[1-9][0-9]{5}$/;
			if( zipCode !="" && !zipCodeReg.test(zipCode) ){
				$("#zipCode").focus();
				 alert("邮政编码填写不正确。");
				 return false;
			}

		  var emailAddress = $("#emailAddress").val().trim();
		  var emailReg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
		  if(!emailReg.test(emailAddress)){
			  $("#emailAddress").val("");
			  $("#emailAddress").focus();
			  alert("电子邮箱格式不正确。");
			  return false;
		  }

		  var account = $.trim($("#account").val());
		  if( account  ==  ""){
				$("#account").focus();
				alert("请填写结算账户户名。");
				return false;
		  }

			var bank = $.trim($("#bank").val());
			if( bank  ==  ""){
				$("#bank").focus();
				alert("请填写结算账户开户行。");
				return false;
			}

			var account_number = $.trim($("#account_number").val());
			if( account_number  ==  ""){
				$("#account_number").focus();
				alert("请填写结算账户开户行。");
				return false;
			}

		if(window.confirm("确认提交？")){
			$("#registerAdditionalForm").submit();
		}
	}

	function chooseUserType(flag){
		if(flag == 0){//个人用户
			$("#idCardTr").css("display","");
			$("#yyzhTr").css("display","none");
		}
		else if(flag == 1){//公司用户
			$("#idCardTr").css("display","none");
			$("#yyzhTr").css("display","");
		}
	}
	
</script>

<style type="text/css">
#main{padding-top: 20px;padding-bottom: 20px;margin: 0 auto;width: 960px;}
.register_title{font-family: SimHei;font-size: 18px;color: #ff0000;padding: 10px 0px 10px 130px;}
</style>

</head>

<body>
<s:actionerror/>
<s:actionmessage/>

<!-- 页面头部  -->
<jsp:include page="/commons/head_member.jsp"></jsp:include>

<form action="${ctx}/member/modify.do" method="post" id="userInfoFrom" name="userInfoFrom">
 <table width="960" border="0" cellspacing="10" cellpadding="0" class="tbl_border" align="center" style="font-family: 宋体;font-size: 14px;color: #666666;">
          	<tr><td width="35%"></td><td style="font-family: 宋体;font-size: 14px;color: #666666;padding-top: 5px;">会员基本资料</td></tr>
            <tr>
              <td align="right">真实姓名<span class="style15">*</span></td>
               <td><input type="text" name="userInfo.username" value="${userInfo.username }" id="username"><s:fielderror fieldName="username" theme="simple"/></td>
            </tr>
            <tr>
            	<td align="right">手机号码<span class="style15">*</span></td>
            	<td><input type="text" name="userInfo.mobile" value="${userInfo.mobile }" id="mobile"></td>
            </tr>
            <tr>
	             <td>
	              	  <!-- 隐藏域  begin  -->
		               <input name="userInfo.id" type="hidden"  id="userId"  value="${userInfo.id }">
		              <!-- 隐藏域  begin  -->
	             </td>
	             <td>
	              	<img src="../images/an24.gif" width="114" height="31" onclick="javascript:modifyUserinfo()" style="cursor: pointer;">
	             </td>
         </tr>
</table>
</form>

<c:if test="${userInfo.administratorFlag == '0' }">
<form action="${ctx}/member/memberAction!modifyAdditionInformation.do" method="post" id="registerAdditionalForm" name="registerAdditionalForm">
<table width="960" align="center" border="0" cellspacing="0" cellpadding="0" style="border: solid #ccc; border-width: 0px 1px 1px 1px;margin:0 auto;background: #fff;">
          <tr>
           	 	<td colspan="2"><div class="register_title">请补充会员资料</div></td>
          </tr>
          <tr>
	            <td class="bt14A" align="right"><span class="style15">*</span>商户名称：</td>
	            <td class="bt14A">
	            	<input name="companyName" type="text" size="40" id="companyName"  maxlength="50" value="${userInfo.companyName }">
	            	<input name="userType" type="radio" value="company" <c:if test="${userInfo.userType == 'company' }">checked="checked"</c:if> onclick="chooseUserType(1)">公司
	            	<input name="userType" type="radio" value="personal" <c:if test="${userInfo.userType == 'personal' }">checked="checked"</c:if> onclick="chooseUserType(0)">个人 
	            </td>
          </tr>
           <tr id="yyzhTr">
		         <td valign="top" class="bt14A" align="right"><span class="style15">*</span>营业执照注册号：</td>
		         <td class="bt14A"><input name="yyzh" type="text" size="40" id="yyzh"  maxlength="50" value="${userInfo.yyzh }"></td>
          </tr>
          <tr id="idCardTr">
	          	<td class="bt14A" align="right"><span class="style15">*</span>身份证：</td>
	          	<td class="bt14A"><input name="idCard" id="idCard" maxlength="20"  size="30" value="${userInfo.idCard }"/></td>
          </tr>
          <tr>
            <td valign="top" class="bt14A" align="right"><span class="style15">*</span>所在地：</td>
            <td valign="top" class="bt14A">
                <select name="province" id="provinceInfoSelect" onchange="changeProvince()">
                        <option value="">选择省份</option>
                        <c:forEach items="${requestScope.provinceInfoList}" var="provinceInfo" varStatus="status">
				             <option value="${ provinceInfo.id}" <c:if test="${userInfo.provinceInfo.id == provinceInfo.id }">selected="selected"</c:if>/> ${ provinceInfo.name}</option>
				        </c:forEach>
                </select>
                <select name="city" id="cityInfoSelect">
                  <option value="">选择县市</option>
                </select>
                <input name="address" type="text" size="50" id="address" value="${userInfo.address} ">
               </td>
          </tr>
          <tr>
          		<td class="bt14A" align="right">邮码：</td>
          		<td class="bt14A"><input name="zipCode" id="zipCode" maxlength="20" size="30" value="${userInfo.zipCode }"/></td>
          </tr>
          <tr>
            <td valign="top" class="bt14A" align="right">业务联系人：</td>
            <td valign="top" class="bt14A"><input name="contact" type="text" size="20" id="contact" maxlength="40" value="${userInfo.contact }"></td>
          </tr>
          <tr>
            <td valign="top" class="bt14A"  align="right">联系电话：</td>
            <td valign="top" class="bt14A"><input name="tel" type="text" size="20" id="tel" maxlength="50" value="${userInfo.tel }">
            </td>
          </tr>
          <tr>
          		<td class="bt14A" align="right"><span class="style15">*</span>电子邮箱：</td>
          		<td class="bt14A"><input name="emailAddress" id="emailAddress" maxlength="50" size="30" value="${userInfo.emailAddress }"/></td>
          </tr>
          
          <tr><td colspan="2"><div class="register_title">请填写结算账户</div></td></tr>
          <tr>
          		<td class="bt14A" align="right"><span class="style15">*</span>户名：</td>
          		<td class="bt14A"><input name="account" id="account" maxlength="50" size="30" value="${userInfo.account }"/></td>
          </tr>
         <tr>
          		<td class="bt14A" align="right"><span class="style15">*</span>开户行：</td>
          		<td class="bt14A"><input name="bank" id="bank" maxlength="50" size="30" value="${userInfo.bank }"/></td>
         </tr>
         <tr>
          		<td class="bt14A" align="right"><span class="style15">*</span>账号：</td>
          		<td class="bt14A"><input name="account_number" id="account_number" maxlength="50" size="30" value="${userInfo.account_number }"/></td>
          </tr>
         <tr>
            <td width="166"> <input name="userInfo.id" type="hidden"  id="userId"  value="${userInfo.id }"></td>
            <td width="539" valign="top" class="nw12a" align="left">
           		 <img src="../images/an24.gif" width="114" height="31" onClick="javascript:checkForm()" style="cursor: pointer ;border: 0"></td>
         </tr>         
</table>
</form>
</c:if>

<jsp:include page="/commons/foot_member.jsp"></jsp:include>

</body>
</html>